package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.system.domain.vo.TbCellBoxModelModelDetail;
import com.ruoyi.system.domain.vo.TbCellBoxModelPowerDetail;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TbCellBoxmodel;
import com.ruoyi.system.service.ITbCellBoxmodelService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2020-06-25
 */
@Controller
@RequestMapping("/system/boxmodel")
public class TbCellBoxmodelController extends BaseController
{
    private String prefix = "system/boxmodel";

    @Autowired
    private ITbCellBoxmodelService tbCellBoxmodelService;

    @RequiresPermissions("system:boxmodel:view")
    @GetMapping()
    public String boxmodel()
    {
        return prefix + "/boxmodel";
    }

    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("system:boxmodel:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TbCellBoxmodel tbCellBoxmodel)
    {
        startPage();
        List<TbCellBoxmodel> list = tbCellBoxmodelService.selectTbCellBoxmodelList(tbCellBoxmodel);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("system:boxmodel:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TbCellBoxmodel tbCellBoxmodel)
    {
        List<TbCellBoxmodel> list = tbCellBoxmodelService.selectTbCellBoxmodelList(tbCellBoxmodel);
        ExcelUtil<TbCellBoxmodel> util = new ExcelUtil<TbCellBoxmodel>(TbCellBoxmodel.class);
        return util.exportExcel(list, "boxmodel");
    }

    /**
     * 新增【请填写功能名称】
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存【请填写功能名称】
     */
    @RequiresPermissions("system:boxmodel:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TbCellBoxmodel tbCellBoxmodel)
    {
        return toAjax(tbCellBoxmodelService.insertTbCellBoxmodel(tbCellBoxmodel));
    }

    /**
     * 修改【请填写功能名称】
     */
    @GetMapping("/edit/{modelId}")
    public String edit(@PathVariable("modelId") Long modelId, ModelMap mmap)
    {
        TbCellBoxmodel tbCellBoxmodel = tbCellBoxmodelService.selectTbCellBoxmodelById(modelId);
        mmap.put("tbCellBoxmodel", tbCellBoxmodel);
        return prefix + "/edit";
    }

    /**
     * 修改保存【请填写功能名称】
     */
    @RequiresPermissions("system:boxmodel:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TbCellBoxmodel tbCellBoxmodel)
    {
        return toAjax(tbCellBoxmodelService.updateTbCellBoxmodel(tbCellBoxmodel));
    }

    /**
     * 删除【请填写功能名称】
     */
    @RequiresPermissions("system:boxmodel:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tbCellBoxmodelService.deleteTbCellBoxmodelByIds(ids));
    }

    /*
    *电池箱型号性能参数
    * */
    @GetMapping("/powerdetail")
    @ResponseBody
    public TbCellBoxModelPowerDetail powerDetail(Long modelId){
        System.out.println(modelId);
        TbCellBoxModelPowerDetail tbCellBoxModelPowerDetail = tbCellBoxmodelService.powerDetail(modelId);
        return tbCellBoxModelPowerDetail;
    }


    /*
    * 电池箱型号模块参数
    * */
    @GetMapping("/modeldetail")
    @ResponseBody
    public TbCellBoxModelModelDetail modelDetail(Long modelId){
        TbCellBoxModelModelDetail tbCellBoxModelModelDetail = tbCellBoxmodelService.modelDetail(modelId);
        return tbCellBoxModelModelDetail;
    }


}
